package com.yifushidai.api;

import com.yifushidai.service.OpenService;
import com.yifushidai.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "开门记录")
@RequestMapping("/api/open")
public class OpenController {

    @Autowired
    private OpenService openService;

    @PostMapping("/queryOpenRecords")
    @ApiOperation(value = "查询开锁记录接口", notes = "查询开锁记录", produces = MediaType.APPLICATION_JSON_VALUE)
    public R queryOpenRecords(@ApiParam(value = "联网盒mac", required = true) @RequestParam String mac,
                              @ApiParam(value = "开始时间", required = true) @RequestParam String startTime,
                              @ApiParam(value = "结束时间", required = true) @RequestParam String endTime,
                              @ApiParam(value = "起始页", required = true) @RequestParam int pageIndex,
                              @ApiParam(value = "页大小", required = true) @RequestParam int pageSize,
                              @ApiParam(value = "上页最后一条记录日期(pageIndex=1)时，lastdate= 1", required = true) @RequestParam String lastdate) throws Exception {
        return openService.queryOpenRecords(mac, startTime, endTime, pageIndex, pageSize, lastdate);
    }

}
